<?php
/* First we check if default destinations for Java and OpenOffice exist */
$office_dir = "";
$java_path ="";
if(is_dir("/usr/lib/openoffice/")) {
  $office_dir= "/usr/lib/openoffice/";
}
if($handle = opendir("/usr/lib/jvm")) {
  while(false !== ($file = readdir($handle))) {
    if(preg_match("/java/", $file) && is_dir("/usr/lib/jvm/".$file)) {
      $java_path = "/usr/lib/jvm/".$file;
     }
  }
}
?>
<div id="kokosivu">
<h2>Welcome to A-HIP</h2>
<p>
Please fill the following information to set up the anonymization environment. A-HIP 
requires Java runtime environment to be installed on server. In order to use any other file
formats than HTML, also OpenOffice is required (headless is fine).
</p>
<p>In Debian based distribution, following packages should do it (with dependencies):
<ul>
<li>openjdk-6-jre-headless</li>
<li>opeonffice.org-headless</li>
</ul>
</p>
<table>
<tr><b>DB information</b></tr>
<tr>
<td>Database type</td>
<td>MySQL</td>
</tr>
<form action="configuration_apply.php" method="POST">
<tr><td>Database hostname</td><td><input type="text" name="dbhost" value="localhost"/></tr>
<tr><td>Database username</td><td><input type="text" name="dbuser" /></tr>
<tr><td>Database password</td><td><input type="password" name="dbpasswd" /></tr>
<tr><td>Database name</td><td><input type="text" name="dbname" /></tr>
<tr><td>Table prefix (optional)</td><td><input type="text" name="tbprefix" /></tr>
<tr><td><b>Locations in filesystem</b></td></tr>
<tr><td>Absolute path to Java*</td><td><input type="text" width="40" name="javapath" value="<?=$java_path?>"/></td></tr>
<tr><td>OpenOffice home directory</td><td><input type="text" width="40" name="officeHome" value="<?=$office_dir?>"/>
<tr><td>User directories **</td><td><input type="text" width="40" name="userdirs" value="<?=dirname(__FILE__)."/users/"?>"/>
</td></tr>
</table>
<input type="submit" value="Set up">
</form>
<p>* Absolute Java path is same as environment variable JAVA_HOME in shell. </p>
<p>** User directories is the location where we save users' documents. If it doesn't 
exist, it will be created. NOTE: Web-server MUST have write access to the directory 
(or its parent directory if it doesn't exist)! </p>

</div>
